package cn.edu.jnu.x2020101356;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    BowlingGame game;
    @Before
    public void setup() throws Exception{
        game = new BowlingGame();
    }
    @Test
    public void test20one() {
        game.rollMany(20,1);
        assertEquals(20, game.getScore());
    }

    @Test
    public void oneStrike(){
        game.rollMany(1,10);
        game.rollMany(18,1);
        assertEquals(30,game.getScore());
    }

    @Test
    public void oneSpare(){
        game.roll(1);
        game.roll(9);//spare
        game.roll(3);
        game.roll(2);
        game.rollMany(16,1);
        assertEquals(34,game.getScore());
    }

    //第四个测试
    @Test
    public void oneStrikeAndOneSpare(){
        game.roll(1);
        game.roll(8);
        game.roll(10);//strike
        game.roll(2);
        game.roll(8);//spare
        game.rollMany(14,1);
        assertEquals(54,game.getScore());
    }

    @Test
    public void twoStrikeAndTwoSpare(){
        game.roll(1);
        game.roll(9);
        game.roll(10);//spare
        game.roll(2);
        game.roll(8);//spare
        game.rollMany(14,2);
        assertEquals(80,game.getScore());
    }
}